#!/bin/sh
set -eu

if [ $# -lt 1 ]; then
  echo 'No task is specified.' >&2
  exit 1
fi

cd $(dirname $0)

case $1 in
  'build' )
    cd build
    ninja
    ;;
  'cmake' )
    mkdir -p build
    cd build
    cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
    ;;
  'init-vcpkg' )
    cd vcpkg
    ./bootstrap-vcpkg.sh
    ./vcpkg install abseil boost-filesystem boost-program-options boost-serialization ceres double-conversion eigen3 flann gsl-lite gtest --triplet x64-linux
    ;;
  'test' )
    cd build
    ctest -V
    ;;
  * )
    echo "Unrecognized task: $1" >&2
    exit 1
    ;;
esac
